package filter;

import java.util.ArrayList;
import java.util.List;

public class FilterDemo {
    public static void main(String[] args) {
        List<Person> persons = new ArrayList<>();
        persons.add(new Person("James","MALE","SINGLE"));
        persons.add(new Person("Alice","FEMALE","MARRIED"));
        persons.add(new Person("Howard","MALE","SINGLE"));
        persons.add(new Person("Kobe","MALE","MARRIED"));
        persons.add(new Person("Anna","FEMALE","SINGLE"));

        Criteria male = new CriteriaMale();
        Criteria female = new CriteriaFemale();
        Criteria single = new CriteriaSingle();
        Criteria singleMale = new AndCriteria(male,single);
        Criteria singleOrFemale = new OrCriteria(female,single);
        System.out.println("MALE:");
        printPersons(male.meetCriteria(persons));
        System.out.println("\nFEMALE:");
        printPersons(female.meetCriteria(persons));
        System.out.println("\nSINGLE:");
        printPersons(single.meetCriteria(persons));
        System.out.println("\nSINGLEMALE:");
        printPersons(singleMale.meetCriteria(persons));
        System.out.println("\nSINGLEORFEMALE:");
        printPersons(singleOrFemale.meetCriteria(persons));
    }

    private static void printPersons(List<Person> persons){
        for (Person person : persons) {
            System.out.println("Person : [ Name : " + person.getName()
                    +", Gender : " + person.getGender()
                    +", Marital Status : " + person.getMaritalStatus()
                    +" ]");
        }
    }
}
